/*
 * @Author: guanyaoming guanyaoming@linklogis.com
 * @Date: 2022-10-25 11:05:05
 * @LastEditors: guanyaoming guanyaoming@linklogis.com
 * @LastEditTime: 2023-06-26 16:27:36
 * @FilePath: \icf-agw-front\vue.config.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
const { defineConfig } = require("@vue/cli-service");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require("path");
function resolve(dir) {
    return path.join(__dirname, dir);
}

const proxyServerObj = {
    dev: "http://icfdev.prov.10086.cn:8001",
    test: "http://icfsit.prov.10086.cn",
    prod: "",
};
const proxyEnv = "dev";

module.exports = defineConfig({
    runtimeCompiler: true,
    lintOnSave: false,
    transpileDependencies: true,
    outputDir: "dist/provpc",
    publicPath: "./",
    devServer: {
        proxy: proxyServerObj[proxyEnv],
        client: {
            progress: true,
        },
        compress: true,
        open: true,
        host: "frontdev.icfdev.hq.cmcc",
        port: 8567,
    },
    productionSourceMap: false,

    configureWebpack: {
        plugins: [
            new CopyWebpackPlugin({
                patterns: [
                    {
                        from: resolve("static/externalPlugin/pdf"),
                        to: resolve("dist/pdf"),
                    },
                ],
            }),
        ],
    },
    css: {
        extract: true, // 是否将组件中的 CSS 提取至一个独立的 CSS 文件中 (而不是动态注入到 JavaScript 中的 inline 代码)。
        sourceMap: false,
        loaderOptions: {
            scss: {
                // scss 混入
                prependData: `
              @import "@/assets/styles/mixin.scss";
              `,
            },
        },
    },
    chainWebpack(config) {
        // set svg-sprite-loader
        config.module.rule("svg").exclude.add(resolve("src/svgIcon")).end();
        config.module
            .rule("svgIcon")
            .test(/\.svg$/)
            .include.add(resolve("src/svgIcon"))
            .end()
            .use("svg-sprite-loader")
            .loader("svg-sprite-loader")
            .options({
                symbolId: "icon-[name]",
            })
            .end();

        config.plugin("html").tap((args) => {
            return [
                Object.assign(args[0], {
                    title: "笔点-用心做简洁，可自定义的网址导航",
                }),
            ];
        });
    },
});
